package org.blankie.model;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.blankie.model.DriverOperationListener.OperationType;

public class DriverOperationsLogger implements DriverOperationListener {
    
    private final Logger logger;
    
    private final Level level;
    
    public DriverOperationsLogger(String logger, Level level) {
        this.logger = Logger.getLogger(logger);
        this.level = level;
    }

    @Override
    public void operationStarted(OperationType type, BlkResource<? extends BlkPath> object) {
        logger.log(level, String.format("Operation %s started on %s", type, object));
    }

    @Override
    public void operationTerminated(OperationType type, BlkResource<? extends BlkPath> object, Object result) {
        logger.log(level, String.format("Operation %s terminated on %s with result %s", type, object, result));
    }

}
